package org.swidgets.base.stooltip;

import org.swidgets.base.BorderStyleRepository;
import org.swidgets.base.slabel.SLabel;
import org.swidgets.base.spanels.SFrame;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.SimplePanel;


	
	public class SToolTip extends Composite{
		
		
		private final SFrame sframe=new SFrame();
		private SimplePanel simplePanel=new SimplePanel();
		private HorizontalPanel hp = new HorizontalPanel();
		private Image icon ;
		private String message;
		
		public void initPanel(){
			simplePanel.add(sframe);				
			sframe.setStyle(BorderStyleRepository.toolTip);
			hp.setSpacing(5);
		}
		
		public SToolTip(){
			super();
			this.initWidget(simplePanel);
			initPanel();
			icon = new Image(SToolTipTypeRepository.error.getIcona());
			message = "Errore";
			
		}
		
		public SToolTip(SToolTipType toolTipType, String strMessage){
			super();
			this.initWidget(simplePanel);
			initPanel();
			icon = new Image(toolTipType.getIcona());
			setMessage(toolTipType,strMessage);
		}
		
		public void setMessage(SToolTipType sToolTipType, String string) {
			
			this.message = string;
			hp.clear();
			hp.add(icon);
			hp.add(new SLabel(message));
			sframe.clear();
			sframe.setBodyWidget(hp);
			
		}
}
